package com.aya.aop.custom.aopalliance;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class MyAdvisor implements MethodInterceptor {
    private static final Logger logger = LoggerFactory.getLogger(MyAdvisor.class);

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        logger.info("before,class:{},method:{}", invocation.getThis().getClass(),
                invocation.getMethod().getName());
        Object proceed = invocation.proceed();
        logger.info("after,class:{},method:{}", invocation.getThis().getClass(),
                invocation.getMethod());
        return proceed;
    }
}
